<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('公告详情')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-notice-edit" th:object="${notice}">
        <input id="noticeId" name="noticeId" th:field="*{noticeId}"  type="hidden">
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">公告标题：</label>
            <div class="col-sm-6">
                <input id="noticeTitle" name="noticeTitle" th:field="*{noticeTitle}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">发布人：</label>
            <div class="col-sm-6">
                <input id="createBy" name="createBy" th:field="*{createBy}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">发布时间：</label>
            <div class="col-sm-6">
                <input id="createTime" name="createTime" th:field="*{createDate}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="panel panel-success" style="height: 290px;">
                    <div class="panel-heading">
                        <h3 class="panel-title">公告内容</h3>
                    </div>
                    <div class="panel-body" id="noticeContent">
                        <textarea id="noticeContent_1" disabled hidden th:field="*{noticeContent}"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
<script type="text/javascript">
    var prefix = ctx + "system/notice";
    $(function() {
        $("#noticeContent").html($("#noticeContent_1").val());
    });

    // 上传文件
    function sendFile(file, obj) {
        var data = new FormData();
        data.append("file", file);
        $.ajax({
            type: "POST",
            url: ctx + "common/upload",
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'json',
            success: function(result) {
                if (result.code == web_status.SUCCESS) {
                    $(obj).summernote('editor.insertImage', result.url, result.fileName);
                } else {
                    $.modal.alertError(result.msg);
                }
            },
            error: function(error) {
                $.modal.alertWarning("图片上传失败。");
            }
        });
    }

    $("#form-notice-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var sHTML = $('.summernote').summernote('code');
            $("#noticeContent").val(sHTML);
            $.operate.save(prefix + "/edit", $('#form-notice-edit').serialize());
        }
    }
</script>
</body>
</html>
